<%@ page language="java" import="java.util.*,com.jspsmart.upload.*,java.sql.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'MyJsp.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
<jsp:useBean id="su" class="com.jspsmart.upload.SmartUpload" scope="page"></jsp:useBean>
<%
	su.initialize(pageContext);//上传初始化
	su.service(request,response);
	su.upload();
	su.setAllowedFilesList("jpeg,bmp,gif");
	su.setDeniedFilesList("exe,bat,jsp,htm,html");
	su.setMaxFileSize(204800);
	su.setTotalMaxFileSize(12040);
	String s;
	int t = su.getFiles().getCount();
	for(int i = 0;i<t;i++){
	com.jspsmart.upload.File f= su.getFiles().getFile(i);
	if(!f.isMissing()){
	f.saveAs("guanggao/"+f.getFileName());
	}
	Class.forName("com.mysql.jdbc.Driver");
	Connection con = DriverManager.getConnection("jdbc:mysql://localhost/jobs?useUnicode=true&characterEncoding=UTF8","root","");
	Statement st = con.createStatement();
	s =basePath+"guanggao/"+f.getFileName();
	st.execute("insert into ad(id,lujing,createtime) values (null,'"+s+"',now())");
			out.println("Size = " + f.getSize() + "<BR>");
			out.println("FileName = " + f.getFileName() + "<BR>");
			out.println("FileExt = " + f.getFileExt() + "<BR>");
			out.println("FilePathName = " + f.getFilePathName() + "<BR>");
			out.println("ContentType = " + f.getContentType() + "<BR>");
			out.println("ContentDisp = " + f.getContentDisp() + "<BR>");
			out.println("TypeMIME = " + f.getTypeMIME() + "<BR>");
			out.println("SubTypeMIME = " + f.getSubTypeMIME() + "<BR>");
			}
	 %>
  </body>
</html>
